package cn.kgc.springboot02.controller;

import cn.kgc.springboot02.entity.Student;
import cn.kgc.springboot02.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/7/19
 * @Description:
 */
@Controller
@RequestMapping("student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping("list")
    public String getList(Model model) {
        List<Student> students = studentService.getList();
        model.addAttribute("students", students);
        return "student";  //  转发
    }

    @GetMapping("page")
    public Map<String, Object> getPage(Integer page, Integer limit) {

        return studentService.getPage(page, limit);
    }

}
